﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;


namespace BreakArray
{
    class Board
    {
        //const int CELLWIDTH = 70;
        //const int CELLHEIGHT = 50;
        //const int ROWSIZE = 10;

        //The board
        //public Piece[] pieceArray = new Piece[99];

        //Creates the 2D array of pieces (10 x 10)
        public Piece[,] pieceArray = new Piece[9, 9];

        //public Board()
        //{
        //    for (int x = 0; x < 99; x++)
        //    {
        //        pieceArray[x] = new Piece();
        //    }
        //}

        //Creates a peice object for each part of the array
        public Board()
        {
            for (int x = 0; x < 9; x++)
            {
                for (int y = 0; y < 9; y++)
                {
                    pieceArray[x, y] = new Piece();
                }
            }
        }

         //public void Initialize()
         //{
         //   for (int x = 0; x < 99; x++)
         //       {
         //           pieceArray[x].Initialize(new Vector2(70 * x, 50 * x), new Rectangle(0,0,70,50), Vector2.Zero, new Vector2(1.0f), 1.0f);
         //           pieceArray[x].SetPosition(2);
         //       }

         //   //pieceArray[1].SetPosition(1);
         //   //pieceArray[56].SetPosition(1);
         //   //pieceArray[77].SetPosition(2);
         //   //pieceArray[23].SetPosition(2);
         //}

        public void Initialize()
        {
            for (int x = 0; x < 9; x++)
            {
                for (int y = 0; y < 9; y++)
                {
                    //Initilizes position, source, depth, scale
                    pieceArray[x, y].Initialize(new Vector2((70 * x),
                                            (50 * y)),
                                            new Rectangle(0, 0, 70, 50), Vector2.Zero,
                                            new Vector2(1.0f), (1.0f));
                    //Sets each element of the array to be blank
                    pieceArray[x, y].SetPosition(0);
                }
            }
        }

         //public void LoadContent(SpriteBatch spriteBatch, Texture2D player1Texture, Texture2D player2Texture)
         //{
         //    // Load the content for the pieces
         //    for (int x = 0; x < 99; x++)
         //    {
         //        pieceArray[x].LoadContent(spriteBatch, player1Texture, player2Texture);
         //    }
         //}

        //Loads the textures for each player's piece
        public void LoadContent(SpriteBatch spriteBatch, Texture2D player1Texture, Texture2D player2Texture)
        {
            for (int x = 0; x < 9; x++)
            {
                for (int y = 0; y < 9; y++)
                {
                    pieceArray[x, y].LoadContent(spriteBatch, player1Texture, player2Texture);
                }
            }
        }
        //public GetCoordinates(unsigned int arrayIndex)
        //{
        //// Get the column by essentially dropping the first digit
        //unsigned int col = arrayIndex % ROWSIZE;
        //// Find the row by subtracting the column number from the total array index and dividing by ROWSIZE
        //// This is only safe because we know that arrayIndex - col will always be a multiple of ROWSIZE
        //unsigned int row = (arrayIndex - col) / ROWSIZE;
	
        //// Return a constructed rectangle
        //return Rectangle(col*CELLWIDTH, row*CELLHEIGHT, CELLWIDTH, CELLHEIGHT);
        //}

    }
}
